package automata;

import automatagen.*;
import java.util.*;

public class Header_tdc_automata
{
  protected static String nl;
  public static synchronized Header_tdc_automata create(String lineSeparator)
  {
    nl = lineSeparator;
    Header_tdc_automata result = new Header_tdc_automata();
    nl = null;
    return result;
  }

  public final String NL = nl == null ? (System.getProperties().getProperty("line.separator")) : nl;
  protected final String TEXT_1 = "//*************************************************************************\\\\" + NL + "//*************************************************************************\\\\" + NL + "//*********** \t\t        UFPE/Cin - Greco\t\t***********\\\\" + NL + "//*********** \t\t http://www.cin.ufpe.br/~greco \t\t***********\\\\" + NL + "//***********\t\t\t\t\t\t\t***********\\\\" + NL + "//***********\t\t\t\t\t\t\t***********\\\\" + NL + "//*********** \t\t    By Rafael Melo Macieira\t\t***********\\\\" + NL + "//***********\t\t\t\t\t\t\t***********\\\\" + NL + "//***********\t\t    E-mail: rmm2@cin.ufpe.br\t\t***********\\\\" + NL + "//*************************************************************************\\\\" + NL + "//*************************************************************************\\\\" + NL + "//File: tdc_automata_";
  protected final String TEXT_2 = ".h" + NL + "//Desc: Automata for the temporal check of the" + NL + "// ";
  protected final String TEXT_3 = " service's" + NL + "//*************************************************************************\\\\" + NL + "" + NL + "#ifndef TDC_AUTOMATA_";
  protected final String TEXT_4 = "_H" + NL + "#define TDC_AUTOMATA_";
  protected final String TEXT_5 = "_H" + NL + "#include \"tdc_automata.h\"" + NL + " " + NL + "class TDC_Automata_";
  protected final String TEXT_6 = " : public TDC_Automata{" + NL + "" + NL + " private:" + NL + "" + NL + "  enum StateID {" + NL + "    In,";
  protected final String TEXT_7 = NL + "    P";
  protected final String TEXT_8 = ",";
  protected final String TEXT_9 = NL + "    A," + NL + "    R" + NL + "  };" + NL + "" + NL + "  StateID currentState;" + NL + "" + NL + "  static const StateID INITIAL_STATE = In;" + NL + "" + NL + "  void printRejection(StateID stateID);" + NL + "  int checkState(StateID stateID);" + NL + "  int checkInitialState();" + NL + "  StateID getNextState(StateID stateID);" + NL + "  void refreshVariables(VarList* mainVarList);" + NL + "" + NL + " public:" + NL + "  void reset();" + NL + "  int runStep(bool access_type, VarList* mainVarList);" + NL + "  TDC_Automata_drv_init(VarList* mainVarList);" + NL + "  //unsigned int lcd_var_data_cmd;" + NL + "  //unsigned int lcd_var_cmd;" + NL + "  //char access_type;" + NL + "" + NL + "};" + NL + "" + NL + "#endif";

  public String generate(Object argument)
  {
    final StringBuffer stringBuffer = new StringBuffer();
    
Automata automata = (Automata)argument;
ArrayList<Tupla> tuplas = automata.generateStates();
//Properties prop;

    stringBuffer.append(TEXT_1);
    stringBuffer.append(automata.getName());
    stringBuffer.append(TEXT_2);
    stringBuffer.append(automata.getName());
    stringBuffer.append(TEXT_3);
    stringBuffer.append(automata.getName().toUpperCase());
    stringBuffer.append(TEXT_4);
    stringBuffer.append(automata.getName().toUpperCase());
    stringBuffer.append(TEXT_5);
    stringBuffer.append(automata.getName());
    stringBuffer.append(TEXT_6);
    for (int i=0;i<tuplas.size()-1;i++){
    stringBuffer.append(TEXT_7);
    stringBuffer.append(i);
    stringBuffer.append(TEXT_8);
    }
    stringBuffer.append(TEXT_9);
    return stringBuffer.toString();
  }
}
